/*
 * Copyright 2011 Clean GWT
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cleangwt.showcase.client.page;

import com.cleangwt.bootstrap.client.style.Btn;
import com.cleangwt.bootstrap.client.style.Styles;
import com.cleangwt.bootstrap.client.ui.Button;
import com.cleangwt.bootstrap.client.ui.ButtonGroup;
import com.cleangwt.page.client.PageContext.CodeSplit;
import com.cleangwt.page.client.PageContext.Page;
import com.cleangwt.page.client.PageContext.Prefetch;
import com.cleangwt.showcase.client.component.ShowcasePage;
import com.cleangwt.showcase.client.resource.PageGroups;
import com.cleangwt.user.client.ui.Lay;
import com.google.gwt.user.client.ui.FlowPanel;

/**
 * 
 * @author Jess
 * @version 1.0
 * @since 1.0
 */
@Prefetch(PageGroups.BASE_WIDGET)
@CodeSplit
@Page
public class ButtonDemo extends ShowcasePage {

  public ButtonDemo() {
    super(
        "Button",
        "Integrate bootstrap's button & button group styles."
        + " Refer to <a href='http://getbootstrap.com/css/#buttons'>Bootstrap</a>",
        "ButtonDemo.java");
    // final BaseWidgetConstants c = GWT.create(BaseWidgetConstants.class);

    FlowPanel layout = new FlowPanel();
    // Base Types
    Button btn1 = new Button("Default");
    Button btn2 = new Button("Primary");
    Button btn3 = new Button("Success");
    Button btn4 = new Button("Info");
    Button btn5 = new Button("Warning");
    Button btn6 = new Button("Danger");
    Button btn7 = new Button("Link");

    // Sizing
    Button btnLg1 = new Button("Large");
    Button btnLg2 = new Button("Large");
    Button btnMd1 = new Button("Default");
    Button btnMd2 = new Button("Default");
    Button btnSm1 = new Button("Small");
    Button btnSm2 = new Button("Small");
    Button btnXs1 = new Button("Extra Small");
    Button btnXs2 = new Button("Extra Small");
    // block level
    Button btnBlock1 = new Button("Block Level");
    Button btnBlock2 = new Button("Block Level");
    ButtonGroup btng = new ButtonGroup();

    btng.addButton("button2", "value2");
    btng.addButton("button3", "value3");
    btng.addButton("button4", "value4");
    btng.addDropdown("ButtonDropdown").setDropup(true).addLink("Link1", "#").addLink("Link2", "#");

    layout.add(Lay.heading("Base Types"));
    layout.add(Lay.p("Set type <code>btn-default</code>, <code>btn-primary</code>, "
        + "<code>btn-success</code>,<code>btn-info</code>,<code>btn-warning</code>, "
        + "<code>btn-danger</code> or <code>btn-link</code> for base appearance."));
    layout.add(Lay.p(btn1, Btn.primary(btn2), Btn.success(btn3), Btn.info(btn4), Btn.warning(btn5),
        Btn.danger(btn6), Btn.link(btn7)));
    layout.add(Lay.heading("Sizing"));
    layout
        .add(Lay
            .p("Add style <code>btn-lg</code>, <code>btn-sm</code>, or <code>btn-xs</code> for additional sizes."));
    layout.add(Lay.p(Btn.lg(Btn.primary(btnLg1)), Btn.lg(btnLg2)));
    layout.add(Lay.p(Btn.primary(btnMd1), btnMd2));
    layout.add(Lay.p(Btn.sm(Btn.primary(btnSm1)), Btn.sm(btnSm2)));
    layout.add(Lay.p(Btn.xs(Btn.primary(btnXs1)), Btn.xs(btnXs2)));
    layout.add(Lay.p("Add style <code>btn-block</code> for full width of it's parent."));
    layout.add(Styles.well(Lay
        .p(Btn.block(Btn.style(btnBlock1)), Btn.block(Btn.primary(btnBlock2)))));
    layout.add(Lay.heading("Group"));
    layout.add(Lay.p("To stick buttons together, use ButtonGroup."));
    layout.add(btng);

    this.setContentWidget(layout);
  }

}
